Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

232
Views
What is the purpose of the "@" symbol in Javascript classes?

In this example on AdonisJS, the Post class definition includes @column sections. Can someone explain what this does? I assume it's creating multiple instances of the 'column' class within the Post class as member variables, each instance having a different name and data type. But how does this work and what is the @ symbol for?

  import { column, BaseModel } from '@ioc:Adonis/Lucid/Orm'

  export default class Post extends BaseModel {
    @column({ isPrimary: true })
    public id: number

    @column()
    public title: string

    @column()
    public description: string
  }

Would the following be equivalent (without the defined data types)?

export default class Post extends BaseModel
{
   constructor()
   {
      this.id = new column({ isPrimary: true });
      this.title = new column();
      this description = new column();
   }
}

UPDATE:

After realizing AdonisJS is written in TypeScript, I found this, which answers the question.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

These are called "decorators", a proposed javascript feature.

https://github.com/tc39/proposal-decorators

The proposal has gone through several iterations already. TypeScript and babel both have their own implementations of decorators.

Decorators can modify whole classes or class fields, e.g. by calling Object.defineProperty(classPrototype, key, {...}).

What exactly the decorator does is dependent on it's implementing function.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!